package evolutionaryballoons.behavior.genetic;

public class DecisionNode extends MultipleNode {
	protected float limit;
	protected Sources source;
	
	@Override
	public void perform(NodeInterface nodeInterface) {
		if (nodeInterface.dataProvider.getData(source) <= limit) {
			if (leftNode != null) 
				leftNode.perform(nodeInterface);
		} else {
			if (rightNode != null)
				rightNode.perform(nodeInterface);
		}
	}

	public Node clone() {
		DecisionNode clone = new DecisionNode();
		clone.leftNode = (leftNode != null) ? leftNode.clone() : null;
		clone.rightNode = (rightNode != null) ? rightNode.clone() : null;
		clone.limit = limit;
		clone.source = source;
		
		return clone;
	}
}
